local thbattle__youxiang_nilin = fk.CreateSkill {

  name = "thbattle__youxiang_nilin",

  tags = {},

}



thbattle__youxiang_nilin:addEffect("viewas", {
  mute = true,
  prompt = "#thbattle__youxiang_nilin",
  pattern = "slash",
  card_filter = function(self, player, to_select, selected)
    return #selected < 1 and Fk:currentRoom():getCardArea(to_select) == Player.Hand
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then
      return nil
    end
    local c = Fk:cloneCard("danmu__slash")
    c.skillName = thbattle__youxiang_nilin.name
    c:addSubcard(cards[1])
    return c
  end,
  before_use = function(self, player, use)
    player.room:broadcastPlaySound(Thbattle_path .. "audio/skill/thbattle__youxiang_nilin1")
    player.room:notifySkillInvoked(player, thbattle__youxiang_nilin.name, "defensive")
    return
  end,
  enabled_at_play = function(self, player)
    return player.phase == Player.NotActive
  end,
  enabled_at_response = function(self, player)
    return player.phase == Player.NotActive
  end,
})

thbattle__youxiang_nilin:addEffect(fk.TargetConfirming, {
  prompt = "#thbattle__youxiang_nilin_trigger-prompt",
  mute = true,
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(thbattle__youxiang_nilin.name) and data.card and data.from ~= player and
        data.card:isCommonTrick() and data.card.multiple_targets ~= true and
        data.card.skillName ~= thbattle__youxiang_nilin.name
  end,
  on_use = function(self, event, target, player, data)
    player:broadcastSkillInvoke("thbattle__youxiang_nilin", 2)
    player.room:notifySkillInvoked(player, thbattle__youxiang_nilin.name, "masochism")
    data:cancelTarget(player)
    data.nullified = true
    local card = Fk:cloneCard("danmuzhan__duel", data.card.suit, data.card.number)
    card.skillName = thbattle__youxiang_nilin.name
    player.room:useCard({
      from = data.from,
      tos = { player },
      card = card,
    })
  end
})

return thbattle__youxiang_nilin
